package com.upb.webserver.dao.mapper;

import com.upb.webserver.dao.entity.TbMessage;
import com.upb.webserver.dao.entity.TbMessageExample;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;
import java.util.List;
import java.util.Optional;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;

public interface TbMessageMapper {

    @Select({ "<script>", "select", TbMessageSqlProvider.ALL_COLUMN_FIELDS, "from tb_message", "where id in", "<foreach collection='messageIdList' item='messageId' open='(' separator=',' close=')'>", "#{messageId}", "</foreach>", "</script>" })
    @Results({ @Result(column = "id", property = "id", jdbcType = JdbcType.INTEGER, id = true), @Result(column = "content", property = "content", jdbcType = JdbcType.VARCHAR), @Result(column = "type", property = "type", jdbcType = JdbcType.TINYINT), @Result(column = "gmt_create", property = "gmtCreate", jdbcType = JdbcType.TIMESTAMP), @Result(column = "gmt_modified", property = "gmtModified", jdbcType = JdbcType.TIMESTAMP) })
    List<TbMessage> listByIds(@Param("messageIdList") List<Integer> messageIdList);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_message
     *
     * @mbg.generated
     */
    @SelectProvider(type = TbMessageSqlProvider.class, method = "countByExample")
    long countByExample(TbMessageExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_message
     *
     * @mbg.generated
     */
    @DeleteProvider(type = TbMessageSqlProvider.class, method = "deleteByExample")
    int deleteByExample(TbMessageExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_message
     *
     * @mbg.generated
     */
    @Delete({ "delete from tb_message", "where id = #{id,jdbcType=INTEGER}" })
    int deleteByPrimaryKey(Integer id);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_message
     *
     * @mbg.generated
     */
    @Insert({ "insert into tb_message (content, type, ", "gmt_create, gmt_modified)", "values (#{content,jdbcType=VARCHAR}, #{type,jdbcType=TINYINT}, ", "#{gmtCreate,jdbcType=TIMESTAMP}, #{gmtModified,jdbcType=TIMESTAMP})" })
    @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "id", before = false, resultType = Integer.class)
    int insert(TbMessage record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_message
     *
     * @mbg.generated
     */
    @InsertProvider(type = TbMessageSqlProvider.class, method = "insertSelective")
    @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "id", before = false, resultType = Integer.class)
    int insertSelective(TbMessage record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_message
     *
     * @mbg.generated
     */
    @SelectProvider(type = TbMessageSqlProvider.class, method = "selectByExample")
    @Results({ @Result(column = "id", property = "id", jdbcType = JdbcType.INTEGER, id = true), @Result(column = "content", property = "content", jdbcType = JdbcType.VARCHAR), @Result(column = "type", property = "type", jdbcType = JdbcType.TINYINT), @Result(column = "gmt_create", property = "gmtCreate", jdbcType = JdbcType.TIMESTAMP), @Result(column = "gmt_modified", property = "gmtModified", jdbcType = JdbcType.TIMESTAMP) })
    List<TbMessage> selectByExample(TbMessageExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_message
     *
     * @mbg.generated
     */
    @Select({ "select", "id, content, type, gmt_create, gmt_modified", "from tb_message", "where id = #{id,jdbcType=INTEGER}" })
    @Results({ @Result(column = "id", property = "id", jdbcType = JdbcType.INTEGER, id = true), @Result(column = "content", property = "content", jdbcType = JdbcType.VARCHAR), @Result(column = "type", property = "type", jdbcType = JdbcType.TINYINT), @Result(column = "gmt_create", property = "gmtCreate", jdbcType = JdbcType.TIMESTAMP), @Result(column = "gmt_modified", property = "gmtModified", jdbcType = JdbcType.TIMESTAMP) })
    TbMessage selectByPrimaryKey(Integer id);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_message
     *
     * @mbg.generated
     */
    @UpdateProvider(type = TbMessageSqlProvider.class, method = "updateByExampleSelective")
    int updateByExampleSelective(@Param("record") TbMessage record, @Param("example") TbMessageExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_message
     *
     * @mbg.generated
     */
    @UpdateProvider(type = TbMessageSqlProvider.class, method = "updateByExample")
    int updateByExample(@Param("record") TbMessage record, @Param("example") TbMessageExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_message
     *
     * @mbg.generated
     */
    @UpdateProvider(type = TbMessageSqlProvider.class, method = "updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(TbMessage record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_message
     *
     * @mbg.generated
     */
    @Update({ "update tb_message", "set content = #{content,jdbcType=VARCHAR},", "type = #{type,jdbcType=TINYINT},", "gmt_create = #{gmtCreate,jdbcType=TIMESTAMP},", "gmt_modified = #{gmtModified,jdbcType=TIMESTAMP}", "where id = #{id,jdbcType=INTEGER}" })
    int updateByPrimaryKey(TbMessage record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_message
     *
     * @mbg.generated
     */
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    @Insert({ "<script>", "insert into tb_message (content, ", "type, gmt_create, ", "gmt_modified)", "values<foreach collection=\"list\" item=\"detail\" index=\"index\" separator=\",\">(#{detail.content,jdbcType=VARCHAR}, ", "#{detail.type,jdbcType=TINYINT}, #{detail.gmtCreate,jdbcType=TIMESTAMP}, ", "#{detail.gmtModified,jdbcType=TIMESTAMP})</foreach></script>" })
    int batchInsert(List<TbMessage> list);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_message
     *
     * @mbg.generated
     */
    @SelectProvider(type = TbMessageSqlProvider.class, method = "getOneByExample")
    @Results({ @Result(column = "id", property = "id", jdbcType = JdbcType.INTEGER, id = true), @Result(column = "content", property = "content", jdbcType = JdbcType.VARCHAR), @Result(column = "type", property = "type", jdbcType = JdbcType.TINYINT), @Result(column = "gmt_create", property = "gmtCreate", jdbcType = JdbcType.TIMESTAMP), @Result(column = "gmt_modified", property = "gmtModified", jdbcType = JdbcType.TIMESTAMP) })
    Optional<TbMessage> getOneByExample(TbMessageExample example);
}
